import { useMemberStore } from "../store";
import type { FilterItem } from "../types/global";
import type {
  CertificateItem,
  CertificateListItem,
  EducationItem,
  ExperienceAddParams,
  ExperienceDeleteParams,
  ExperienceEditParams,
  ExperienceListItem,
  IntentionEditParams,
  IntentionItem,
} from "../types/profile";

import http from "../utils/http";

export const ExperienceUrl = {
  workList: "WorkExperience/all",
  workCreate: "WorkExperience/create",
  workDelete: "WorkExperience/destory",
  workUpdate: "WorkExperience/update",
  eduList: "EducationExperience/all",
  eduCreate: "EducationExperience/create",
  eduDelete: "EducationExperience/destory",
  eduUpdate: "EducationExperience/update",
  skillList: "Skills/all",
  skillCreate: "Skills/create",
  skillDelete: "Skills/destory",
  skillUpdate: "Skills/update",
  honorList: "Honor/all",
  honorCreate: "Honor/create",
  honorDelete: "Honor/destory",
  honorUpdate: "Honor/update",
};

// 会员中心-学历
export const postProfileEducation = (lang?:string) => {
  return http<EducationItem[]>({
    url: "Educational/all",
    method: "POST",
    data: {
      lang,
    },
  });
};

// 会员中心-证书
export const postProfileCertificate = (lang?: string) => {
  return http<CertificateItem[]>({
    url: "Certificate/all",
    method: "POST",
    data: {
      lang,
    },
  });
};

// 证书列表
export const postCertificateList = () => {
  return http<CertificateListItem[]>({
    url: "PersonalCertificate/all",
    method: "POST",
  });
};

// 证书添加
export const postCertificateAdd = (data: any) => {
  return http<any>({
    url: "PersonalCertificate/create_upload",
    method: "POST",
    data,
  });
};

// 删除证书
export const postCertificateDelete = (id: number) => {
  return http<any>({
    url: "PersonalCertificate/destory",
    method: "POST",
    data: { id },
  });
};

// 个人意向
export const postMemberIntention = (lang: string) => {
  return http<IntentionItem>({
    url: "Member/resume",
    method: "POST",
    data: {
      lang,
    },
  });
};

// 个人意向-编辑
export const postMemberIntentionEdit = (data: IntentionEditParams) => {
  return http<any>({
    url: "Member/update",
    method: "POST",
    data,
  });
};

// 经验列表
export const postExperienceList = (url: string, data) => {
  return http<ExperienceListItem[]>({
    url,
    method: "POST",
    data,
  });
};

// 经验添加
export const postExperienceCreate = (
  url: string,
  data: ExperienceAddParams
) => {
  return http<ExperienceListItem>({
    url,
    method: "POST",
    data,
  });
};

// 经验删除
export const postExperienceDelete = (
  url: string,
  data: ExperienceDeleteParams
) => {
  return http<any>({
    url,
    method: "POST",
    data,
  });
};

// 经验编辑
export const postExperienceUpdate = (
  url: string,
  data: ExperienceEditParams
) => {
  return http<any>({
    url,
    method: "POST",
    data,
  });
};

// 我的考试====================

// 证书列表
export const postExamCertList = (id) => {
  let { profile } = useMemberStore();
  return http<any>({
    url: "/ProfessionMaterial/my",
    method: "POST",
    data: {
      course_id: id,
      member_id: profile?.id,
    },
  });
};

// 创建证书
export const postExamCertCreate = (data) => {
  return http<any>({
    url: "/ProfessionMaterial/create",
    method: "POST",
    data,
  });
};
// 删除证书
export const postExamCertDestory = (id) => {
  return http<any>({
    url: "/ProfessionMaterial/destory",
    method: "POST",
    data: {
      id,
    },
  });
};
